﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200002F RID: 47
	public class NullableInt16Formatter : IMessagePackFormatter<short?>
	{
		// Token: 0x060000AB RID: 171 RVA: 0x00003E2D File Offset: 0x0000222D
		private NullableInt16Formatter()
		{
		}

		// Token: 0x060000AC RID: 172 RVA: 0x00003E35 File Offset: 0x00002235
		public int Serialize(ref byte[] bytes, int offset, short? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteInt16(ref bytes, offset, value.Value);
		}

		// Token: 0x060000AD RID: 173 RVA: 0x00003E5C File Offset: 0x0000225C
		public short? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new short?(MessagePackBinary.ReadInt16(bytes, offset, out readSize));
		}

		// Token: 0x04000023 RID: 35
		public static readonly NullableInt16Formatter Instance = new NullableInt16Formatter();
	}
}
